<%@ page contentType="text/html; charset=UTF-8"%>
<!-- JSTL을 사용하기위해 필요함 -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	request.setCharacterEncoding("UTF-8");
	String cp = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		
		$("#help .kkk:visible").hide();
		$("#help .help_td").click(function(event) {
		    event.preventDefault ? event.preventDefault() : event.returnValue = false;
		    var $targetTD = $(this).parents("tr").next().find(".kkk");
		    if($targetTD.is(":visible"))
		        $targetTD.css("display","none");
		    else
		        $targetTD.css("display","table-cell");
		});   
	
	}); 		

	function commentInsert(){
		var f = document.myForm;
		
		f.action = "<%=cp%>/reply/insert.action";
		f.submit();
	}
	
	function sendIt() {
		var f = document.myForm;

		if (!f.content.value) {
			alert("\n내용을 입력하세요. ");
			f.content.focus();
			return;
		}
		f.action = "<%=cp%>/qa.action";
		f.submit();
	}
	
	function search(){
		var f = document.myForm;
		var searchValue = f.searchValue.value;
		var pageNum = f.pageNum.value;
		var str = "?searchValue=" + searchValue + "&pageNum=" + pageNum; 
		f.action = "<%=cp%>/list.action" + str;
		f.submit();
	}
	
	function deleted(num){
		
		var mode = "comment";
		var f = document.myForm;
		f.action = "<%=cp%>/reply/commentDelete.action?num=" + num + "&mode=" + mode; 
		f.submit();
	}
	
	function reply_delete(num){
		
		var mode = "reply";
		var f = document.myForm;
		f.action = "<%=cp%>/reply/commentDelete.action?commentNum=" + num + "&mode=" + mode;
		f.submit();
		
	}
	
	
	

</script>


</head>
<body>
<form action="" method="post" name="myForm">
<!-- ------------------------------------------------------ -->
<!-- 					구매 포인트 						-->
<!-- ------------------------------------------------------ -->

<table width="900px" align="center">
	<tr>
		<td colspan="2"><img src="<%=cp%>/data/image/buypoint.jpg"></td>
	</tr>
	
	<tr>
		<td><font size="2pt" style="font: bold;">구매정보</font></td>
		<td><font size="2pt" style="font: bold;">안내사항</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">최대수량 : ${p_info.max_qty}</font></td>
		<td><font size="2pt" color="#6e6e6e">수령일을 포함하여 7일이후 환불 불가합니다.</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">1인당 구매가능수량 : ${p_info.pp_qty}</font></td>
		<td><font size="2pt" color="#6e6e6e">도서산간 지방에는 추가배송요금이 발생할 수 있습니다.</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">택배사 : ${p_info.delivery_company}</font></td>
		<td><font size="2pt" color="#6e6e6e">고객 변심에 의한 환불의 경우, 왕복택배비는</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">배송비여부 : ${p_info.delivery_price}</font></td>
		<td><font size="2pt" color="#6e6e6e">5,000원으로 고객이 부담합니다.</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">일회배송 최대수량 : ${p_info.delivery_maxqty}</font></td>
		<td><font size="2pt" color="#6e6e6e">상품의 개봉으로 또는 고객의 부주의로 인하여</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">배송방식 : ${p_info.delivery_method}</font></td>
		<td><font size="2pt" color="#6e6e6e">상품가치 훼손시에는 교환, 반품이 불가합니다. </font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">출고일 : 구매시부터 익일 순차 배송</font></td>
		<td><font size="2pt" color="#6e6e6e">브랜드 : ${p_info.brand}</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">(주말,공휴일 및 택배사 사정에 따라 지연될 수 있습니다.)</font></td>
		<td><font size="2pt" color="#6e6e6e">원산지 : ${p_info.made_country}</font></td>
	</tr>
	
	<tr>
		<td><font size="2pt" color="#6e6e6e">빠른배송을 위해 배송마감시간 후 취소를 하실 수 없습니다.</font></td>
		<td><font size="2pt" color="#6e6e6e">사이즈 : 상세페이지 표기</font></td>
	</tr>
	
	<tr>
		<td></td>
		<td><font size="2pt" color="#6e6e6e">세탁방법 : ${p_info.clean_method}</font></td>
	</tr>
	
	<tr>
		<td></td>
		<td><font size="2pt" color="#6e6e6e">소재 : ${p_info.made_stuff}</font></td>
	</tr>
	
	<tr>
		<td></td>
		<td><font size="2pt"  color="#6e6e6e">품질보증기준 : 미사용시 7일이내 교환가능</font></td>
	</tr>
	
	<tr>
		<td></td>
		<td>
			<c:if test="${!empty p_info.event}">
				<font size="2pt" style="color:#66CDAA">
					*이벤트*<br/>
					${p_info.event}
				</font>
			</c:if>
		</td>
	</tr>
</table>
	
<!-- ------------------------------------------------------ -->
<!-- 					구매 포인트 끝						-->
<!-- ------------------------------------------------------ -->

<!-- ------------------------------------------------------ -->
<!-- 					Q&A 게시판							-->
<!-- ------------------------------------------------------ -->
<div id="description">
<table width="900px" align="center" border="0">
	<tr>
		<td>
			<font size="6pt" style=" color:red; font:bold;" >Q&amp;A</font>
			<font size="2pt" style="font:bold;">딜에대해서 궁금한점을 물어보세요!</font>
		</td>
		<td style="padding-top:15px">
			<font size="2pt" color="#6e6e6e">* 해당 딜과 관련되지 않은 내용이나 비방, 홍보글, 반복 문의, 도배 글은 삭제되는거 아시죠?</font>
		</td>
	</tr>
	
	<tr>
		<td colspan="2">
			<textarea rows="5" cols="106" name="content" 
				style="border: 2px solid;
					border-color: #aaaaaa;"></textarea>						
			<img width="85px" style="position:relative;top:4px;" height="85px" src="<%=cp%>/data/image/qa_button.jpg" onclick="sendIt();">
		</td>		
	</tr>
</table>
</div>

<table width="900px" align="center">
	<tr height="30">
		<td align="right" style="margin-right: 50px;">
			<input type="hidden" name="pageNum" value="${pageNum}"/>
			<input type="text" name="searchValue" size="35" height="30"
				style="border: 2px solid; border-color: #aaaaaa;">			
			<img src="<%=cp%>/data/image/search.jpg" onclick="search();" style="position:relative;top:6px;">			
		</td>
	<tr>
</table>

<table width="900px" align="center" id="help" border="0" cellpadding="0" cellspacing="0">	
	
	<c:if test="${totalDataCount != 0}">
	<tr>
		<td colspan="4">
			<hr width="900px" align="center" size="2"  color="#cccccc"/>
		</td>
	</tr>
	</c:if>
	
	<c:forEach var="dto" items="${qa_list}">

	<tr>
		<td align="left" style="padding-left: 30px;">
			<font size="3pt" color="#828282">${dto.userID}</font>
		</td>
		
		<td align="left">
			<font size="2pt">${dto.content} &nbsp;&nbsp;</font> <font size="1pt" color="#828282">${dto.created}</font>
		</td>
		
		<td align="right" style="padding-right: 30px;">
			<img src="<%=cp%>/data/image/delete.jpg" onclick="deleted(${dto.num});"/>
			<img src="<%=cp%>/data/image/rp.jpg"  class="help_td" >			
		</td>
	</tr>
	
	<tr>
		<td class="kkk" colspan="4" align="center" style="background: #eeeeee;padding-left: 30px;" height="80;">
			<input type="hidden" name="nums" value="${dto.num}"/>
			<textarea cols="105" rows="3" name="replyContents" style="background-color:#FDF5E6;font-size:10pt; border:1px solid #cccccc;"></textarea>
			<img style="position:relative; top:3px;" src="<%=cp%>/data/image/reply.jpg" onclick="commentInsert();">
		</td>
	</tr>
	
	<c:forEach var="reply" items="${reply_list}">
		<c:if test="${reply.num == dto.num}">
		<tr height="30">
			<td align="left" style="padding-left:50px; background-color: #eeeeee;">
				<img src="<%=cp%>/data/image/rp1.jpg"><font size="3pt" color="#828282">${reply.userID}</font>
			</td>
			<td style="background-color: #eeeeee">
				<font size="2pt">${reply.replyContent} &nbsp;&nbsp;</font> <font size="1pt" color="#828282">${reply.created}</font>
			</td>
			<td align="right" style="padding-right:50px; background-color: #eeeeee;">								
				<img src="<%=cp%>/data/image/delete.jpg" align="right" onclick="reply_delete(${reply.commentNum});" >
			</td>
		</tr>
		</c:if>
	</c:forEach>
	
	<tr>
		<td colspan="4">
		<table width="900px">
			<tr><td>
				<hr width="900px" align="center" size="2" color="#cccccc"/>
			</tr><tr>
		</table>
		</td>
	</tr>

</c:forEach>

</table> 


<table width="900px" align="center">
	<tr>				
		<td align="center">
			<c:if test="${!empty totalDataCount}">
				${pageIndexList}
			</c:if>
			<c:if test="${totalDataCount == 0}">
				<font size="2pt" color="#828282">등록된 댓글이 없습니다.</font>
			</c:if>
		<td>				
	</tr>
</table> 
<!-- ------------------------------------------------------ -->
<!-- 					Q&A 게시판	끝						-->
<!-- ------------------------------------------------------ -->





</form>
</body>
</html>